package com.mars.junit.mq;

import java.util.HashMap;
import java.util.Map;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import com.mars.component.mq.JmsQueueMessage;
import com.mars.component.mq.JmsTopicMessage;

public class ActiveMQTest1 extends AbstractTest {
	
	@Autowired
	private JmsQueueMessage jmsQueueMessage ;
	
	@Autowired
	private JmsTopicMessage jmsTopicMessage ;
	
	/**
	 * 发送队列消息，字符串
	 */
	@Test
	public void testQueue1() {
		this.jmsQueueMessage.send("queue.test1", "HelloWorld");
		
	}
	/**
	 * 发送队列消息，对象
	 */
	@Test
	public void testQueue2() {
		this.jmsQueueMessage.send("queue.test2", new MQEntity(100, "小黄人", "xhr@126.com"));
	}
	/**
	 * 发送队列消息，对象
	 */
	@Test
	public void testQueue3() {
		this.jmsQueueMessage.send("queue.test3", new MQEntity(200, "超人", "cr@126.com"));
	}
	/**
	 * 发送队列消息，对象
	 */
	@Test
	public void testQueue4() {
		Map<String, Object> map = new HashMap<String, Object>() ;
		map.put("name", "超人") ;
		map.put("age", 300) ;
		map.put("address", "广州") ;
		this.jmsQueueMessage.send("queue.test4", map);
	}
	/**
	 * 发送队列消息，对象
	 */
	@Test
	public void testQueue5() {
		Map<String, Object> map = new HashMap<String, Object>() ;
		map.put("name", "努尔哈赤") ;
		map.put("age", 600) ;
		map.put("address", "广州") ;
		this.jmsQueueMessage.send("queue.test5", map);
	}
	/**
	 * 发送队列消息，字符串
	 */
	@Test
	public void testQueue6() {
		this.jmsQueueMessage.send("HelloWorld");
	}
	
	
	
	
	/**
	 * 发送订阅消息
	 */
	@Test
	public void testTopic1() {
		this.jmsTopicMessage.publish("HelloWorld");
	}
	
	/**
	 * 发送订阅消息
	 */
	@Test
	public void testTopic2() {
		this.jmsTopicMessage.publish("topic.test1", "HelloWorld");
	}
	
}
